package com.qf.springcloud.order.controller;

import com.qf.springcloud.order.feifn.ItemFeignClient;
import com.qf.springcloud.order.pojo.Order;
import com.qf.springcloud.order.pojo.OrderItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/orders")
public class OrderController {

    private ItemFeignClient itemFeignClient;

    @Autowired
    public void setItemFeignClient(ItemFeignClient itemFeignClient) {
        this.itemFeignClient = itemFeignClient;
    }

    @GetMapping("/order/{id}")
    public Order getOrderById(@PathVariable Integer id){
        Order order=new Order();
        order.setId(id);
        order.setAddress("狮驼岭2楼");
        OrderItem orderItem = itemFeignClient.getItemById(id + 1);
        order.setOrderItem(orderItem);
        return order;
    }
}
